﻿using System.Collections.Generic;
using System.Diagnostics;

namespace WpfApplication1
{
	[DebuggerDisplay("{ToString()}")]
	public class Region
	{
		public string Name { get; set; }
		public int Index { get; set; }
		public IEnumerable<Region> SubRegions { get; set; }

		public bool Equals(Region other)
		{
			if (ReferenceEquals(null, other))
			{
				return false;
			}
			if (ReferenceEquals(this, other))
			{
				return true;
			}
			return Equals(other.Name, Name) && Equals(other.Index, Index);
		}

		public override bool Equals(object obj)
		{
			if (ReferenceEquals(null, obj))
			{
				return false;
			}
			if (ReferenceEquals(this, obj))
			{
				return true;
			}
			if (obj.GetType() != typeof (Region))
			{
				return false;
			}
			return Equals((Region) obj);
		}

		public override int GetHashCode()
		{
			unchecked
			{
				return ((Name != null ? Name.GetHashCode() : 0)*397) ^ (Index != null ? Index.GetHashCode() : 0);
			}
		}

		public override string ToString()
		{
			return string.Format("Region: Name: {0}, Index: {1}", Name, Index);
		}
	}
}
